<link type="text/css" href="/styles/style.css" rel="stylesheet" />


<script type="text/javascript">

$(function() {
	$('#duedate').datepick({minDate: 0,dateFormat:'mm-dd-yy'});
	$('#end_date').datepick({minDate: 0});

	$('#duetime').timePicker({
	  show24Hours: false,
	  separator: '.',
	  step: 15});
 

});
$(document).ready(function(){                
                $("#select3").fcbkcomplete({
                    json_url: "/tasks/index/get-contacts",
                    addontab: true,                   
                    maxitems: 50,
                    input_min_size: 0,
                    height: 10,
					onselect : getVale,
                    cache: true,
					width : 300,
                    select_all_text: "select",
                });
            });	
function getVale()
{
    //selecting only "selected" users
    $("#select3 option:selected").each(function() {
        var user_id = $(this).val();        
        if(isNaN(user_id))
		{
			alert(user_id+ ' is not existing user');
			 $(this).val('');


			//return false;
		}
    });

}
</script>


	<div id="createtask">
		<div id="inline1" style="width:600px; min-height:300px; padding:10px 10px;">
		<div class="PopUp">
		<p class="Title">New Task</p>
		<?php if($ctx->edit!=""){ ?>
		<form enctype="multipart/form-data" id="messageform" name="messageform" method="POST" action="/tasks/index/update-task/<?php echo $ctx->task_id;?>">
		<? } else{?>
		<form enctype="multipart/form-data" id="messageform" name="messageform" method="POST" action="/tasks/index/create-task" >
		<? } ?>
		<div class="NewTask">
		<div class="pad_t15">
		<?php if($ctx->edit!="") { ?>
		<label class="wid60"><strong>Task Name</strong></label><input type="text" id="taskname" name="taskname" value="<?php echo $ctx->task_details['task_name']; ?>" class="wid250" /> 
		<? } else { ?>
		<label class="wid60"><strong>Task Name</strong></label><input type="text" id="taskname" name="taskname" class="wid250" /> 
		<? } ?>
		<?php if($ctx->edit!="") { ?>
		<label class="wid60"><strong>Due Date</strong></label><input type="text" id="duedate" name="duedate" value="<?php echo $ctx->task_details['due_date']; ?>" class="wid100" />
		<? } else{?>
        <label class="wid60"><strong>Due Date</strong></label><input type="text" id="duedate" name="duedate" class="wid100" />
		 <? } ?>
		 <!--<input type="text" size="12" id="inputField" />-->
		 <?php if($ctx->edit!="") { ?>
		 <input type="text" name="duetime" id="duetime" value="<?php echo $ctx->task_details['due_time']; ?>" class="textfield_2"  title="Duetime" style="width:65px"/>
		 <? }else{ ?>
		 <input type="text" name="duetime" id="duetime" value="Time" class="textfield_2"  title="Duetime" style="width:65px" onfocus="clearField(this.id,'Time');" onblur="addValuetoField(this.id,'Time');"/>
		<? } ?>
	   <div class="clear"></div>
        </div>
		<div class="pad_t15">
        <label class="wid100" style="text-align:left">
		<a href="javascript:void(0);" id="showAssign" onclick="showAssignDiv();">Assigned To</a>
		<a href="javascript:void(0);" id="hideAssign" onclick="hideAssignDiv();" style="display:none;">Assigned To</a>
		</label>
              
        <label  class="wid60"><a href="javascript:void(0);">Budget</a></label>
        <span id="cost">
        <select>
        <option>$</option>
        </select>
		<?php if($ctx->edit!="") { ?>
		<input type="text" id="amount" name="amount" value="<?php echo $ctx->task_details['cost']; ?>" class="wid100" />
		 <? } else {?>
        <input type="text" id="amount" name="amount" class="wid100" />
        <? } ?>
		</span>
        <div id="rec">
        <label  class="wid60"><strong>Reccurance</strong></label>
        <select class="fontGry" id="Reccurance" name="reccurance">
		<?php if($ctx->edit!="")  { ?>
		<?php if($ctx->task_details['Reccurance']=="None") { ?>
		<option value="0" selected="selected">None</option>
		 <? } else {?>
        <option value="0">None</option>
		<? } ?>
		<?php if($ctx->task_details['Reccurance']=="Weekly") { ?>
		<option value="1" selected="selected">Weekly </option>
		<? } else {?>
		<option value="1">Weekly </option>
		<? } ?>
		<?php if($ctx->task_details['Reccurance']=="Bi-Weekly") { ?>
		<option value="2" selected="selected">Bi-Weekly</option>
		<? } else {?>
		<option value="2">Bi-Weekly</option>
		 <? } ?>
		 <? } else{?>
		 <option value="0">None</option>
		 <option value="1">Weekly </option>
		 <option value="2">Bi-Weekly</option>
		 <? } ?>
        </select>

        </div>
        <div class="clear"></div>
        </div>
        <div id="assignto" class="AsgWid" style="display:none;">
		<?php if($ctx->edit!="") {?>
		
		<select id="select3" name="select3">
		<?php if(count($ctx->user_details)>0) { ?>
			<?php foreach($ctx->user_details as $user_details) { ?>
			<option value="<?php echo $user_details['user_id']; ?>" class="selected"><?php echo $user_details['first_name']; ?></option>
			<? } } ?>
		</select>
		
		<? } else{?>
		<select id="select3" name="select3">   
			
		</select>
		<? } ?>
		<div class="clear"></div>
        </div>
		<!--<div class="pad_t15" id="showconnect">
        <label class="wid100" style="text-align:left"><a href="javascript:void(0);" onclick="showConnectDiv();">connect to service</a></label>
		<div class="clear"></div>
		</div>
		<div class="pad_t15" id="hideconnect" style="display:none;">
        <label class="wid100" style="text-align:left"><a href="javascript:void(0);" onclick="hideConnectDiv();">connect to service</a></label>
		<div class="clear"></div>
		</div>
		<div id="connectService" class="AsgWid" style="display:none;">
		<div class="pad_t15"><label>Email&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label><input type="text" name="email" id="email" value=""/><div class="clear"></div></div>
		<div class="pad_t15"><label>Password</label><input type="password" name="pwd" id="pwd" value=""/><div class="clear"></div></div>
		<div class="clear"></div>
        </div> -->
		<div class="pad_t15">
		<label class="wid60">&nbsp;</label>
		<select style="width:420px;" id="event" name="event">
				<option value="0" >Link to Existing Event</option>
				<?php 
				$i=0;
				while($i<($ctx->eventCount))
				{ ?>
					<?php if($ctx->events[$i]['event_id'] == $ctx->task_details['event_id']) { ?>
				<option value="<?php echo $ctx->events[$i]['event_id']; ?>" selected="selected"><?php echo $ctx->event_name; ?></option>
				<?php } else { ?>
					<option value="<?php echo $ctx->events[$i]['event_id']; ?>"><?php echo $ctx->events[$i]['text']; ?></option>  
					<?php } ?>
				<?php $i++; }?>
		</select>
		<div id="event1">
		
		</div>
		<div class="Fleft pad_18" id="or1">or</div><div class="Fleft pad_18" id="showevent"><a class="Button" href="javascript:void(0);" onclick="showEventDiv();"><span>Add Event</span></a></div>
		
		<div class="clear"></div>
        </div>
        <div style="padding-left:250px; padding-top:20px"><a class="Button" href="javascript:void(0);" onclick="validate(document.messageform);"><span>Save</span></a><a class="Button" href="javascript:void(0);" onclick="javascript:tb_remove();"><span>Cancel</span></a></div>
		<div class="clear"></div>
		</div>
		<?php if($ctx->edit!=""){ ?>
		</form>
		<? } else { ?>
		</form>
		<?}?>
		</div>
		</div>
	</div>
	<div class="clear"></div>
<script type="text/javascript">
//<![CDATA[	
function showCostDiv()
{
	$('#cost').show();
	
}
function validate(frm)
{
	if($('#taskname').val()=="")
	{
		alert("${php: this.translate('errmsg_task_name')}");return false;
	}
	if($('#duedate').val()=="")
	{
		alert("${php: this.translate('errmsg_due_date')}");return false;
	}
	$('#messageform').submit();
}
function showAssignDiv()
{
	$('#assignto').show();
	$('#showAssign').hide();
	$('#hideAssign').show();
	
	
}
function hideAssignDiv()
{
	$('#assignto').hide();
	$('#showAssign').show();
	$('#hideAssign').hide();
	
	
}
function cancel()
{
$('#createtask #btncancel').live('click',function(){
		$('#createtask').fadeOut();

		});
}
function showConnectDiv()
{
	
	$('#connectService').show();
	$('#showconnect').hide();
	$('#hideconnect').show();

	
}
function hideConnectDiv()
{
	
	$('#connectService').hide();
	$('#hideconnect').hide();
	$('#showconnect').show();

	
}
function showEventDiv()
{
	$('#event').hide();
	$('#event1').show();
	$('#showevent').hide();
	$('#or1').hide();
	document.getElementById('event1').innerHTML = '<input type="text" name="eventname" id="eventname" style="width: 516px;" value=""/>';

}
 function clearField(id,itemvalue)
{
	if($("#"+id).val()==itemvalue){
		$("#"+id).val('');
	}
}
function addValuetoField(id,itemvalue)
{
	if($("#"+id).val()==''){
		$("#"+id).val(itemvalue);
	}
}
//]]>
</script>
